
import sys,os,django
django.setup()
#加载app从而可以从Arya 导入包

from Stark import settings
from Arya import models,action_list

class ArgvMangement(object):
    def __init__(self,argvs):
        self.argvs = argvs
        self.argv_parse()
    def help_msg(self):
        print('Avaliable model :')
        for register_module in action_list.actions:
            print(register_module)

    def argv_parse(self):
        print(self.argvs)
        if len(self.argvs)<2:
            self.help_msg()
            exit()
        module_name = self.argvs[1]
        if '.' in module_name:
            mod_name,mod_method = module_name.split('.')
            module_instance = action_list.actions.get(mod_name)
            if module_instance:
                module_instance(self.argvs,models)
            else:
                print('invalid module name argument')